import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { NgModule, CUSTOM_ELEMENTS_SCHEMA, NO_ERRORS_SCHEMA } from '@angular/core';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
// global layout
import { LayoutComponent } from './pages/global/layout/layout.component';
// common widget
import { AppHeaderComponent } from './widgets/header/header.component';
import { AppSidebarComponent } from './widgets/sidebar/sidebar.component';
import { AppFooterComponent } from './widgets/footer/footer.component';
import { AppBreadcrumbComponent } from './widgets/breadcrumb/breadcrumb.component';

// common service
import { AuthGuardService } from './services/auth-guard.service';
import { HttpClientService } from './services/http-client.service';


import { HttpModule, Http, RequestOptions } from '@angular/http';
import { AuthHttp, AuthConfig } from 'angular2-jwt';

// import {PreloadSelectedModules} from './services/preload.service';
import { TreeModule, TreeNode } from 'primeng/primeng';

// 企业年金modal
import { AnnuityFileComponent } from "../app/pages/annuity/modal/file/file.component";
// 养老金产品modal
import { OldageProductFileComponent } from "../app/pages/oldage-product/modal/file/file.component";
// 社保基金modal
import { SocialFileComponent } from "../app/pages/social/modal/file/file.component";
// 养老基金modal
import { OldageFileComponent } from "../app/pages/oldage/modal/file/file.component";
import { AppPaginationModule } from './widgets/pagination/pagination.module';

import { FileUploadModule } from 'ng2-file-upload';
/**
 * [authHttpServiceFactory 定义存储token的位置和名称]
 * @param {Http}           http    [description]
 * @param {RequestOptions} options [description]
 */
export function authHttpServiceFactory(http: Http, options: RequestOptions) {
  return new AuthHttp(new AuthConfig({
    tokenName: 'token',
    tokenGetter: (() => sessionStorage.getItem('token')),
    globalHeaders: [{ 'Content-Type': 'application/json' }],
  }), http, options);
}
import { FlatpickrModule, FLATPICKR } from '../assets/angularx-flatpickr';
import * as flatpickr from 'flatpickr';

export function flatpickrFactory() {
  return flatpickr;
}
@NgModule({
  declarations: [
    AppComponent,
    LayoutComponent,
    AppHeaderComponent,
    AppSidebarComponent,
    AppFooterComponent,
    AppBreadcrumbComponent,
    AnnuityFileComponent,
    OldageFileComponent,
    OldageProductFileComponent,
    SocialFileComponent
  ],
  entryComponents: [
    AnnuityFileComponent,
    OldageFileComponent,
    OldageProductFileComponent,
    SocialFileComponent
  ],
  imports: [
    BrowserModule,
    FormsModule,
    HttpModule,
    AppRoutingModule,
    AppPaginationModule,
    FileUploadModule,
    TreeModule,
    FlatpickrModule.forRoot({
      provide: FLATPICKR,
      useFactory: flatpickrFactory
    })
  ],
  providers: [{
    provide: AuthHttp,
    useFactory: authHttpServiceFactory,

    deps: [Http, RequestOptions]
  }, AuthGuardService, HttpClientService],
  bootstrap: [AppComponent]
})
export class AppModule {
}
